import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';


//学习flutter的界面结构  以及一些生命周期的常识

//StatelessWidget 内部没有保存状态，UI界面创建后不会发生改变
//StatefulWidget  内部保存状态，调用setState方法更新UI

//State  launch -->
// initState[插入到Widget树中时调用（1次）] -->
// didChangeDependencies[当state对象的依赖关系发生变化时调用] -->
// build[构建Widget时调用]( <--didUpdateWidget[widget重建的时候调用]) -->
// deactivate[当state对象从树中移除时调用] -->、
// dispose[当state对象从树中永久移除，一般在此处释放资源] -->destroy





class NewPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return NewPageState();
  }
}

class NewPageState extends State<NewPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        color: Colors.white,
        padding: const EdgeInsets.fromLTRB(16, 120, 16, 0),
        child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: logo() + crateBen() + crateBen1()),
      ),
    );
  }
}

List<Widget> logo() {
  return <Widget>[
    Image(
      image: AssetImage("assets/images/app_logo.png"),
      width: 100,
      height: 100,
      fit: BoxFit.fitHeight,
    ),
    SizedBox(
      height: 10,
      width: 10,
    ),
    Text("Welcome",
        style: TextStyle(
            color: Colors.black,
            fontSize: 10,
            decorationStyle: TextDecorationStyle.dashed),
        textAlign: TextAlign.center)
  ];
}

List<Widget> crateBen() {
  return <Widget>[
    SizedBox(height: 118),
    Material(
      child: RaisedButton(
        onPressed: null,
        color: Colors.blue,
        disabledColor: Colors.blue,
        padding: EdgeInsets.symmetric(vertical: 12),
        child: Text("按钮2号",
            style: TextStyle(color: Colors.white, fontSize: 16),
            textAlign: TextAlign.center),
        shape: RoundedRectangleBorder(
            side: BorderSide(color: Colors.blue),
            borderRadius: BorderRadius.all(Radius.circular(5))),
      ),
    )
  ];
}

List<Widget> crateBen1() {
  return <Widget>[
    SizedBox(height: 16),
    Material(
      child: FlatButton(
        onPressed: null,
        color: Colors.blue,
        disabledColor: Colors.grey,
        padding: EdgeInsets.symmetric(vertical: 12),
        child: Text("按钮1号",
            style: TextStyle(color: Colors.white, fontSize: 16),
            textAlign: TextAlign.center),
        shape: RoundedRectangleBorder(
            side: BorderSide(color: Colors.blue),
            borderRadius: BorderRadius.all(Radius.circular(5))),
      ),
    )
  ];
}
